//Copyright 2012 Trevin Liberty
//GNU GPL v3
//Author: Trevin Liberty
//
//Base Class: Entity
//Used to implement an Archer Entity

#ifndef ARCHER_H
#define ARCHER_H

#include <allegro5\allegro5.h>

#include "Entity.h"
#include "States\StateMachine.h"
#include "States\ArcherOwnedStates.h"
#include "Animator.h"
#include "../Structs.h"
#include "../Sprite/Arrow.h"

//The maximum number of arrows a single archer 
//	can have in the air at any one time.
const int NUM_ARROWS = 8;

//SEE: Top of file.
class Archer : public Entity {
private:
	StateMachine<Archer>* stateMachine;

	static Slide* slideWalking;
	static Slide* slideLooking;
	static Slide* slideAttacking;

	static Slide* slideWalkingComp;
	static Slide* slideLookingComp;
	static Slide* slideAttackingComp;

	Animator animator;

	Arrow* arrows[NUM_ARROWS];

	void loadImages();
	void updateArrows();
	void drawArrows(Point<float> camXY);

public:
	//SEE: Entity.h
	Archer(int maxHealth, Map* map, AStar* aStar);

	//Returns the Archers StateMachine
	StateMachine<Archer>* getStateMachine() {return stateMachine;}

	//Enables a free arrow to be shot at targetPos.
	//If no arrows are free (maximum number of arrows are flying) do nothing.
	//	PARAMS:
	//Point<float> targetPos: The target's screen position, NOT mapArray index.
	void shootArrow(Point<float> targetPos);

	//Returns the current bitmap slide number. SEE: Animator.h
	int getCurrentImageNum() {return animator.getCurrSlideNumber();}

	//Used to update the Archer
	void update();

	//Used to draw the Archer
	void draw(Point<float> cameraPos);

	//SEE: Entity.h
	void deleteImages();

	~Archer();
};

#endif